package com.gua.jbs.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.gua.jbs.pojo.Jbspit;
import com.gua.jbs.service.IAllProductService;
import com.gua.jbs.serviceImpl.AllProductService;
import com.gua.jbs.utility.CollectionUtil;

public class AllProductController extends BaseController {
	private static final Logger logger = Logger
			.getLogger(AllProductController.class);

	private IAllProductService allProdService = null;

	public AllProductController() {
		allProdService = new AllProductService();
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		List<Jbspit> productList = new ArrayList<Jbspit>();

		try{
		productList = allProdService.getAllProductInfo();
		}catch (Exception e) {
			
		}

		boolean isListEmpty = CollectionUtil.isEmptyList(productList);

		if (isListEmpty == false) {
			logger.info("list_allProd==" + productList.size()
					+ productList.get(0).getDesignCode());
			request.setAttribute("productList", productList);
		}
		rd = request.getRequestDispatcher("/pages/jsp/allProductInfo.jsp");
		rd.forward(request, response);
	}
}
